<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>debounce</title>
</head>
<body>
    <input type="text" name="" id="input">
    <script>
       //debounce 函数  
        const debounce = (func,wait=1000) =>{
            let timeout = null;
            return function(){
                if(timeout){
                    clearTimeout(timeout)
                }
                timeout = setTimeout(() =>{
                    func.apply(this,arguments)
                },wait)
    }   
}
        function time(){
                    console.log('输入结束')
                }
document.getElementById('input').addEventListener("input",debounce(time,1500))
       
    </script>
</body>
</html>